package com.surprise.ods.sms;

import lombok.extern.log4j.Log4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.surprise.ods.OdsConfig;

/**
 * SmsService.java
 * @author nick
 * @since 2015年9月14日
 */
@Log4j
@Component
public class SmsService {
	@Autowired 
	private SmsInterfaceServiceLocator smsInterfaceFactory;
	@Autowired
	private OdsConfig odsConfig;
	
	public int sendMessage(String phone, String msg) {
		try {
			SmsInterface_PortType smsInterface = smsInterfaceFactory.getSmsInterface();
			String response = smsInterface.clusterSend(odsConfig.getSmsUsername(), "surprise123", "", phone, msg, null, null);
			log.info("send message to " + phone + " response: " + response);
			return 0;
		} catch(Exception e) {
			throw new RuntimeException(e);
		}
	}
}
